/*
 * @(#)EmailMessage.java
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of DCIVision
 * Ltd ("Confidential Information").  You shall not disclose such Confidential
 * Information and shall use it only in accordance with the terms of the license
 * agreement you entered into with DCIVision Ltd.
 */

package com.dcivision.dms.bean;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.dcivision.framework.bean.AbstractBaseObject;
import com.dcivision.mail.bean.EmailAttachment;
import com.dcivision.mail.bean.EmailAttachmentImpl;
import com.dcivision.mail.bean.EmailMessageImpl;

/**
 EmailMessageToRule.java
 
 This class represent a email message at email archive tracker.
 
 @author      Beyond QU
 @company     DCIVision Limited
 @creation date   02/08/2005
 @version     $Revision: 1.8 $
 */

public class EmailMessageToRule extends AbstractBaseObject {
  
  public static final String REVISION = "$Revision: 1.8 $";
  static final long serialVersionUID = 6845202943820835477L;
  
  private String subject;
  private String oriSubject;  
  private String sender;
  private Date sendDate;
  private String to;
  private String cc;
  
  private int size;
  // if the content is html and have "cid:xxx",this "cid:xxx" will be replaced to "emailArchiveGetImage?xxxx"
  private Object content;
  //original email content
  private String oriContent;  
  
  private int priority;
  
  private boolean haveAttachment;
  private boolean isHtml;  
  
  
  private boolean isTextOnly;
  private boolean isSaved;
  private List attachments = new ArrayList();
  private String messageID;
  private boolean analyzed = false;  
  
  
  
//private String  receipientUserIDStr;  
//private Integer senderUserID ;
  
  private Integer messgeUserID;  
  
  private String emailAllEmailAddress ;
  
  
  private String senderEmailAddress;
  private String toEmailAddress;
  private String ccEmailAddress;  
  
  // this email sender's email address mapping paraDM's user id string  
  private String senderUserIDStr;  
  // this email all email address mapping paraDM's user id string
  private String emailAllUserIDStr;
  //this email to's email address mapping paraDM's user id string
  private String toUserIDStr;  
  //this email cc's email address mapping paraDM's user id string
  private String ccUserIDStr;
  
  private boolean isPrivaeteRule;    
  
  private String ruleCreatorIDStr;
  
  
  public EmailMessageToRule() {
    super();
  }
  
  public void setEmailMessageData(EmailMessageImpl emailMessage) {	  
    this.subject = emailMessage.getSubject();
    this.oriSubject = emailMessage.getOriSubject();
    
    this.sender = emailMessage.getSender();
    this.sendDate =  emailMessage.getSendDate();
    this.to = emailMessage.getTo();
    this.cc = emailMessage.getCc();
    
    this.size = emailMessage.getSize();
    this.content = emailMessage.getContent();
    this.oriContent = emailMessage.getOriContent();
    this.priority = emailMessage.getPriority();
    
    this.isTextOnly = emailMessage.isTextOnly();
    this.isSaved = emailMessage.getIsSaved();
    this.attachments = emailMessage.getAttachments();
    this.messageID = emailMessage.getMessageID();
    this.analyzed = emailMessage.getAnalyzed();
    this.haveAttachment = emailMessage.getHaveAttachment() ;
    this.isHtml = emailMessage.isHtml();
  }  
  
  
  public String getSubject() {
    return subject;
  }
  
  public void setSubject(String subject) {
    this.subject = subject;
  }
  
  public String getOriSubject() {
    return oriSubject;
  }
  
  public void setOriSubject(String oriSubject) {
    this.oriSubject = oriSubject;
  }  
  
  public String getSender() {
    return sender;
  }
  
  public void setSender(String sender) {
    this.sender = sender;
  }
  public Date getSendDate() {
    return sendDate;
  }
  
  public void setSendDate(Date sendDate) {
    this.sendDate = sendDate;
  }
  
  public String getCc() {
    return cc;
  }
  
  public void setCc(String cc) {
    this.cc = cc;
  }
  
  public String getTo() {
    return to;
  }
  
  public void setTo(String to) {
    this.to = to;
  }
  
  public int getSize() {
    return size;
  }
  
  public void setSize(int size) {
    this.size = size;
  }
  
  public Object getContent() {
    return content;
  }
  
  public void setContent(Object content) {
    this.content = content;
  }
  
  public String getOriContent() {
    return oriContent;
  }
  
  public void setOriContent(String oriContent) {
    this.oriContent = oriContent;
  }  
  
  public int getPriority() {
    return priority;
  }
  
  public void setPriority(int priority) {
    this.priority = priority;
  }
  
  public boolean isTextOnly() {
    return isTextOnly;
  }
  
  public void setIsTextOnly(boolean isTextOnly) {
    this.isTextOnly = isTextOnly;
  }
  
  public boolean getHaveAttachment() {
    return haveAttachment;
  }
  
  public void setHaveAttachment(boolean haveAttachment) {
    this.haveAttachment = haveAttachment;
  }
  
  public boolean isHtml() {
    return isHtml;
  }
  
  public void setIsHtml(boolean isHtml) {
    this.isHtml = isHtml;
  }  
  
  public List getAttachments() {
    return attachments;
  }
  
  public void addAttachment(EmailAttachmentImpl emailAttachement) {
    attachments.add(emailAttachement);
  }
  
  public EmailAttachment getAttachment(int id) {
    return (EmailAttachment) attachments.get(id);
  }
  
  public boolean getIsSaved() {
    return isSaved;
  }
  
  public void setIsSaved(boolean isSaved) {
    this.isSaved = isSaved;
  }
  
  public String getMessageID() {
    return messageID;
  }
  
  public void setMessageID(String messageID) {
    this.messageID = messageID;
  }
  
  public boolean getAnalyzed() {
    return analyzed;
  }
  
  public void setAnalyzed(boolean analyzed) {
    this.analyzed = analyzed;
  }  
  
  /**
   * get the messge content 
   * 
   * @return this bean's content object toString();
   */
  public String getMessgeContentString(){
    return  this.content ==null?"":this.content.toString();            
  }
  
  /**
   * get the bean's attatchment list's size 
   * @return
   */
  public int getAttatchmentNum(){
    // to take out the original email attachment so -1
    return  this.attachments == null? 0 :this.attachments.size()-1;
  }
  
  public Integer getMessgeUserID(){
    return this.messgeUserID;
  }
  
  public void setMessgeUserID(Integer messgeUserID){    
    this.messgeUserID = messgeUserID;
  }
  
//public Integer getSenderUserID(){
//return this.senderUserID;
//}
//
//public void setSenderUserID(Integer senderUserID){    
//this.senderUserID = senderUserID;
//}
  
//public void setReceipientUserIDStr(String receipientUserIDStr){
//this.receipientUserIDStr = receipientUserIDStr;
//
//}  
//
//public String getReceipientUserIDStr(){
//return this.receipientUserIDStr;
//}
  
  public boolean getIsPrivaeteRule() {
    return isPrivaeteRule;
  }
  
  public void setIsPrivaeteRule(boolean isPrivaeteRule) {
    this.isPrivaeteRule = isPrivaeteRule;
  }  
  
  
  public void setEmailAllEmailAddress(String emailAllEmailAddress){
    this.emailAllEmailAddress = emailAllEmailAddress;
    
  }  
  
  public String getEmailAllEmailAddress(){
    return this.emailAllEmailAddress;
  }  
  
  
  public void setSenderUserIDStr(String senderUserIDStr){
    this.senderUserIDStr = senderUserIDStr;
    
  }  
  
  public String getSenderUserIDStr(){
    return this.senderUserIDStr;
  }  
  
  public void setEmailAllUserIDStr(String emailAllUserIDStr){
    this.emailAllUserIDStr = emailAllUserIDStr;
    
  }  
  
  public String getEmailAllUserIDStr(){
    return this.emailAllUserIDStr;
  }  
  
  public void setToUserIDStr(String toUserIDStr){
    this.toUserIDStr = toUserIDStr;
    
  }  
  
  public String getToUserIDStr(){
    return this.toUserIDStr;
  }  
  
  public void setCcUserIDStr(String ccUserIDStr){
    this.ccUserIDStr = ccUserIDStr;
    
  }  
  
  public String getCcUserIDStr(){
    return this.ccUserIDStr;
  }  
  
  
  public void setSenderEmailAddress(String senderEmailAddress){
    this.senderEmailAddress = senderEmailAddress;
    
  }  
  
  public String getSenderEmailAddress(){
    return this.senderEmailAddress;
  }    
  
  
  public void setToEmailAddress(String toEmailAddress){
    this.toEmailAddress = toEmailAddress;
    
  }  
  
  public String getToEmailAddress(){
    return this.toEmailAddress;
  }  
  
  
  public void setCcEmailAddress(String ccEmailAddress){
    this.ccEmailAddress = ccEmailAddress;
    
  }  
  
  public String getCcEmailAddress(){
    return this.ccEmailAddress;
  }  
  
  public String getAllEmailAddressAndUserIDGroupIDRoleID(){
    return this.getEmailAllEmailAddress() +","+ this.getEmailAllUserIDStr();
  }
  
  public String getSenderEmailAddressAndUserIDGroupIDRoleID(){
    return this.getSenderEmailAddress() +"," + this.getSenderUserIDStr();
  }
  
  public String getToEmailAddressAndUserIDGroupIDRoleID(){
    return this.getToEmailAddress() +"," + this.getToUserIDStr();
  }
  
  public String getCCEmailAddressAndUserIDGroupIDRoleID(){
    return this.getCcEmailAddress() +"," + this.getCcUserIDStr();
  }
  
  public void setRuleCreatorIDStr(String ruleCreatorIDStr){
    this.ruleCreatorIDStr = ruleCreatorIDStr;
  }
  
  public String getRuleCreatorIDStr(){
    return this.ruleCreatorIDStr;
  }
  
  
  
}
